home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBASE102.ARJ / BTSYNC.C < prev    next >
Text File  |  1991-09-23  |  2KB  |  72 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)btsync.c    1.5 - 91/09/23" */
  5.  
  6. #include <ansi.h>
  7.  
  8. /* ansi headers */
  9. #include <errno.h>
  10.  
  11. /* library headers */
  12. #include <blkio.h>
  13.  
  14. /* local headers */
  15. #include "btree_.h"
  16.  
  17. /*man---------------------------------------------------------------------------
  18. NAME
  19.      btsync - btree synchronize
  20.  
  21. SYNOPSIS
  22.      #include <btree.h>
  23.  
  24.      int btsync(btp);
  25.      btree_t *btp;
  26.  
  27. DESCRIPTION
  28.      The btsync function causes any buffered data for the named btree
  29.      to be written to the file.  The btree remains open and the buffer
  30.      contents remain intact.
  31.  
  32.      btsync will fail if one or more of the following is true:
  33.  
  34.      [EINVAL]       btp is not a valid btree pointer.
  35.      [BTENOPEN]     btp is not open.
  36.  
  37. SEE ALSO
  38.      btclose, btlock, btsetbuf, btsetvbuf.
  39.  
  40. DIAGNOSTICS
  41.      Upon successful completion, a value of 0 is returned.  Otherwise,
  42.      a value of -1 is returned, and errno set to indicate the error.
  43.  
  44. ------------------------------------------------------------------------------*/
  45. #ifdef AC_PROTO
  46. int btsync(btree_t *btp)
  47. #else
  48. int btsync(btp)
  49. btree_t *btp;
  50. #endif
  51. {
  52.     /* validate arguments */
  53.     if (!bt_valid(btp)) {
  54.         errno = EINVAL;
  55.         return -1;
  56.     }
  57.  
  58.     /* check if not open */
  59.     if (!(btp->flags & BTOPEN)) {
  60.         errno = BTENOPEN;
  61.         return -1;
  62.     }
  63.  
  64.     /* synchronize file with buffers */
  65.     if (bsync(btp->bp) == -1) {
  66.         BTEPRINT;
  67.         return -1;
  68.     }
  69.  
  70.     return 0;
  71. }
  72.